<?php
/**
 * Created by PhpStorm.
 * User: hongyeah
 * Date: 2015/11/22
 * Time: 17:20
 */

namespace Admin\Model;

use Common\Common\MyPage;
use Think\Model;

class RecordModel extends Model
{
    public function getRecordList($search,$page_size=15){
        $data = new \stdClass();


        if($search==''){
            $where = array(
                'cardnum' => array('LIKE','%'.$search.'%'),
            );
        }else{
            $where['person_id'] = array('gt',1);
            $where['_string'] = ' (dot_name like '.'\'%'.$search.'%\''.')  OR ( person_name like '.'\'%'.$search.'%\''.') ';
        }

        $count = $this->where($where)->count();

        $Page = new MyPage($count,$page_size);

        $data->show = $Page->showData();

        $dds = $this->field('person_id,person_name,dot_name,order_date,type')->limit($Page->firstRow.','.$Page->listRows)->select();

        $data->data = $dds;

        return $data;
    }
}